package org.example.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.example.service.IPubcommentService;
import org.example.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/pubcomment")
@Api(tags = "评论管理")
public class PubcommentController {
    @Autowired
    private IPubcommentService pubcommentService;


    //查询每个酒店的平均评分
    @ApiOperation("获取特惠机票")
    @RequestMapping("/avgScore")
    public Result avgScore(Integer pid) {
        Double aDouble = pubcommentService.avgScore(pid);
        return new Result("200","查询成功", aDouble);
    }

    //查询每个酒店不同评分的人数
    @ApiOperation("每个酒店不同评分的人数")
    @RequestMapping("/scoreNum")
    public Result scoreNum(Integer pid) {
        Integer[] integers = pubcommentService.countScore(pid, new Integer[]{1, 2, 3, 4, 5});
        return new Result<>("200","查询成功", integers);
    }
}
